-- 饰品技能增强描述tips

local newSkillTipsView = class("newSkillTipsView",function()
    return ccui.Layout:create()
end)

function newSkillTipsView:ctor()
    local function createModuleNode(uiPath, uiNodeName, parent)
        local node = cc.uiloader:load( uiPath )
        local moduleNode = node:getChildByName( uiNodeName )
        moduleNode:retain()
        moduleNode:removeFromParent()
        parent:addChild( moduleNode )
        moduleNode:release()
        return moduleNode
    end
    self.mUINode = createModuleNode( Res.Tips_Skill, "Panel", self )
    self:setContentSize(self.mUINode:getContentSize())
    ccui.Helper:doLayout( self.mUINode )

    self._descNode = self.mUINode:getChildByName("text")
end

function newSkillTipsView:setSkillTipsData( descStr )
    local panelContetsize = self.mUINode:getContentSize()

    local size = self._descNode:getContentSize()
    self._descNode:getVirtualRenderer():setDimensions( size.width, 0 )
    self._descNode:setString( descStr )

    local afterSize = self._descNode:getVirtualRendererSize()
    local descSubHeight = size.height - afterSize.height

    self._descNode:setContentSize( cc.size( size.width, size.height - descSubHeight ) )
    self.mUINode:setContentSize( cc.size( panelContetsize.width, panelContetsize.height - descSubHeight * self._descNode:getScaleY() ) )
    -- print("DescTipsView2 self.mUINode:getContentSize():"..self.mUINode:getContentSize().width.." "..self.mUINode:getContentSize().height)

    self:setContentSize( self.mUINode:getContentSize() )
    ccui.Helper:doLayout( self.mUINode )
end

function newSkillTipsView:setTextColor(color)
    self._descNode:setTextColor(color)
end

return newSkillTipsView
